﻿using System;

using LastLand.Data.Connection;
using LastLand.Data.Global;

using Up2Link.SegString;
using Up2Link.Server;

namespace LastLand.Core.MsgProcessor
{
    public class CMsgInfoServer : IMessageProcessor
    {
        public void ProcessMessage(CMessagePack<CMessageSS> _msgPack)
        {
            Int32 index = _msgPack.index;
            Int32 accountCount = CData.userAccounts.Values.Count;
            Int32 activeCount = 0;
            foreach (CUserAccount account in CData.userAccounts.Values)
            {
                if (account.IsBinded()) activeCount++;
            }
            String infoString = "server\t" + activeCount.ToString() + "\t" + accountCount.ToString() + "\t";

            CMessageSS okInfoMsg = new CMessageSS(CConst.SERVER_MESSAGE_COMPLETE_INFO, 0, CMessageSS.ENCODING_UTF32, infoString);
            CMessagePack<CMessageSS> okInfoMsgPack = new CMessagePack<CMessageSS>(okInfoMsg, index);
            CData.server.Send(okInfoMsgPack);
        }
    }
}
